﻿using System;
using System.Collections.Generic;
using System.Text;
using NIIT.SaoBacDau.Aupi.HospitalManagement.Entities;
using System.Text.RegularExpressions;
using NIIT.SaoBacDau.Aupi.HospitalManagement.DataAccess;
using System.Data.SqlClient;
using System.Data;

namespace NIIT.SaoBacDau.Aupi.HospitalManagement.BusinessLogic
{
    public class BL_E_DrugDetails
    {
      
        public static errordrugdetails Adddrug(E_DrugDetails drug)
        {
            if (string.IsNullOrEmpty(drug.NameDrug) == true)
                return errordrugdetails.ErrorEmpty;
            else if (DAO_E_DrugDetails.AddDrugDetails(drug) == false)
                return errordrugdetails.SqlError;
            else 
                return errordrugdetails.NoError;
        }

        public static errordrugdetails adddrugtype(E_DugType dr)
        {
            if (string.IsNullOrEmpty(dr.NameDrugType))
            {
                return errordrugdetails.ErrorEmpty;
            }
            DAO_E_DugType.AddDrugType(dr);
            return errordrugdetails.NoError;
        }

        public static errordrugdetails Editdrug(E_DrugDetails ar)
        {

            if (string.IsNullOrEmpty(ar.NameDrug) == true)
                return errordrugdetails.ErrorEmpty;
            else if (DAO_E_DrugDetails.EditDrugDetails(ar) == false)
                return errordrugdetails.SqlError;
            else
                return errordrugdetails.NoError;
        }

        public static errordrugdetails Deletedrug(E_DrugDetails ar)
        {
            if (string.IsNullOrEmpty(ar.NameDrug))
            {
                return errordrugdetails.ErrorEmpty;
            }
            DAO_E_DrugDetails.DeleteDrugDetails(ar);
            return errordrugdetails.NoError;
        }

        public static errordrugdetails Searchdrug(E_DrugDetails ar)
        {
            if (string.IsNullOrEmpty(ar.NameDrug))
            {
                return errordrugdetails.ErrorEmpty;
            }
            DAO_E_DrugDetails.SearchDrugDetails(ar);
            return errordrugdetails.NoError;
        }

        public static DataTable RefressDrug()
        {
            return DAO_E_DrugDetails.RefresshDrug();
        }
        public static DataTable Refressh()
        {
            return DAO_E_DrugDetails.RefreshDrugType();
        }

        public static int CountDrug = DAO_E_DrugDetails.DrugDetailsID();

        public static DataTable ListSearch(E_DrugDetails drug_Details)
        {
            return DAO_E_DrugDetails.Search(drug_Details);
        }
    }
}
